package com.avantis.admin.service.impl;

import com.avantis.admin.service.CompanyService;
import com.avantis.common.base.BaseServiceImpl;
import com.avantis.common.entity.Company;
import com.avantis.common.exception.ServiceProcessException;
import com.avantis.common.repository.CompanyRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* @Description:    java类作用描述
* @Author:         kirago
* @CreateDate:     2019/1/12 6:42 PM
* @UpdateRemark:   修改内容
* @Version:        1.0
*/
@Service
@Transactional
public class CompanyServiceImpl extends BaseServiceImpl<CompanyRepository, Company> implements CompanyService {

    @Autowired
    private CompanyService companyService;

    @Autowired
    private CompanyRepository companyRepository;

    @Override
    public boolean checkByCompanyName(String companyname) {
        Company company = repository.findByCompanyName(companyname);
        if (company==null) {
            return true;
        }else {
            return false;
        }
    }

    @Override
    public  void saveCompany(Company company) {
        try {
            save(company);
        } catch (ServiceProcessException e) {
            throw e;
        } catch (Exception e) {
            throw new ServiceProcessException("新增企业失败!");
        }
    }
}
